#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4e5+5;
mt19937 rng(time(0));
map<int,int>mp;
int T,n,M;
ll num[N],Q[N],ans;
namespace IO{
    static int len=0;
    static char ibuf[(1<<20)+5],*iS,*iT,out[(1<<20)+1];
    #define gc() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,1<<20,stdin),(iS==iT?EOF:*iS++):*iS++)
    inline ll read(){
        ll x=0,f=0;char c=gc();
        for(;c<'0'||c>'9';c=gc()) f|=c=='-';
        for(;c>='0'&&c<='9';c=gc()) x=x*10+(c^48);
        return f?-x:x;
    }
    inline void flush(){fwrite(out,1,len,stdout);len=0;}
    inline void pc(char ch){out[len++]=ch;if(len>=1000000) flush();}
    inline void write(ll x){
        static int st[20],top=0;
        if(x<0) pc('-'),x=-x;
        do{st[++top]=x%10,x/=10;}while(x);
        while(top) pc(st[top--]+'0');
        pc('\n');
    }
}using namespace IO;
struct BIT{
	ll c[N];
	int sz[N];
	inline void add(int x,ll val,int cnt){
		for(;x<=M;x+=x&-x) c[x]+=cnt*val,sz[x]+=cnt;
	}
	inline ll ask(int lim){
		ll ans=0;
		int res=0;
		for(int i=18;~i;--i)
			if((res|1<<i)<=M&&lim>=sz[res|1<<i]) res|=1<<i,lim-=sz[res],ans+=c[res];
		return ans;
	}
}T1,T2;
int vis[N];
namespace ST{
	#define k1 (k<<1)
	#define k2 (k<<1|1)
	#define mid ((l+r)>>1)
	#define ls k1,l,mid
	#define rs k2,mid+1,r
	struct info{ll sum,Smx,Smn,sz;}t[N<<2];
	inline info operator+(info A,info B){return {A.sum+B.sum,A.Smx+B.Smx+A.sz*B.sum,A.Smn+B.Smn+A.sum*B.sz,A.sz+B.sz};}
	inline void upd(int x,int v,int k=1,int l=1,int r=M){
		if(l==r) return t[k]={num[x]*v,num[x]*v,num[x]*v,v},void();
		if(x<=mid) upd(x,v,ls);
		else upd(x,v,rs);
		t[k]=t[k1]+t[k2];
	}
	inline void modify(int v){
		vis[v]^=1;
		if(!vis[v]) --n,T1.add(v,num[v],-1),T2.add(M-v+1,num[v],-1),upd(v,0);
		else ++n,T1.add(v,num[v],1),T2.add(M-v+1,num[v],1),upd(v,1);
	}
	inline info askSmx(int S,int k=1,int l=1,int r=M){
		if(!S) return {0,0,0,0};
		if(S>=t[k].sz) return t[k];
		if(S<=t[k2].sz) return askSmx(S,rs);
		return askSmx(S-t[k2].sz,ls)+askSmx(S,rs);
	}
	inline info askSmn(int S,int k=1,int l=1,int r=M){
		if(!S) return {0,0,0,0};
		if(S>=t[k].sz) return t[k];
		if(S<=t[k1].sz) return askSmn(S,ls);
		return askSmn(S,ls)+askSmn(S-t[k1].sz,rs);
	}
	inline ll asksmx(int s){return askSmx(s).Smx;}
	inline ll asksmn(int s){return askSmn(s).Smn;}
	#undef mid
}
inline ll Val(int x){return T2.ask(x)-T1.ask(x+1);}
signed main(){
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	T=read();
	for(int i=1;i<=T;++i) num[i]=Q[i]=read();
	sort(num+1,num+T+1),M=unique(num+1,num+T+1)-num-1;
	for(int i=1;i<=T;++i) Q[i]=lower_bound(num+1,num+M+1,Q[i])-num;
	for(int i=1;i<=T;++i){
		ST::modify(Q[i]),ans=ST::t[1].Smx-ST::t[1].Smn;
		if(n>2&&Val(n/2)>0){
			int l=1,r=n/2,L=n/2,R=n/2;
			while(l<=r){
				int mid=(l+r)>>1;
				if(Val(mid)>0) L=mid,r=mid-1;
				else l=mid+1;
			}
			l=n/2,r=n-1;
			while(l<=r){
				int mid=(l+r)>>1;
				if(Val(mid)>0) R=mid,l=mid+1;
				else r=mid-1;
			}
			ans-=((ST::asksmx(R)-ST::asksmx(L-1))-(ST::asksmn(R+1)-ST::asksmn(L)));			
		}
		write(ans);
	}
	flush();
}